package com.dhl.iterator.college;

import com.dhl.iterator.College;
import com.dhl.iterator.Department;
import com.dhl.iterator.Iterator;

/**
 * @title: ComputerColleage
 * @Author danghailiang
 * @Date: 2022/8/20 16:16
 * @Version 1.0
 */
// 计算机学院
public class ComputerCollege implements College {
    /**
     * 数组
     */
    private Department[] departments;
    /**
     * 保存当前数组的对象个数
     */
    private int numOfDepartment = 0;

    public ComputerCollege() {
        departments = new Department[5];

        addDepartment("Java专业", "Java专业");
        addDepartment("PHP专业", "PHP专业");
        addDepartment("C++专业", "C++专业");

    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department = new Department(name, desc);
        departments[numOfDepartment] = department;
        numOfDepartment += 1;
    }
}
